<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>js  已有值展示</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            table{width:1000px;height:50px;}
            td{width:100px;height:50px;border:1px solid #ccc;}
        </style>
    </head>
    <body>
        <table>
            <tr>
                <td><input type="hidden" value="123"></td>
                <td><input type="hidden" value="234"></td>
                <td><input type="hidden" value="123"></td>
                <td><input type="hidden" value="234"></td>
                <td><input type="hidden" value="123"></td>
                <td><input type="hidden" value="234"></td>
                <td><input type="hidden" value="123"></td>
                <td><input type="hidden" value="234"></td>
            </tr>
        </table>
        <span>AAAAAAAAAAAAAAAAAAA</span>
        <script src="jquery.min.js" type="text/javascript"></script>
        <script  type="text/javascript">
            //方法一
            $("span").click(function () {
                var a = new Array();
                var td_l = $("table td").length;
                for (i = 0; i < td_l; i++) {
                    a[i] = document.getElementsByTagName("input")[i].value;
                }
                for (j = 0; j < a.length; j++) {
                    document.getElementsByTagName("td")[j].innerHTML = a[j];
                }
            });
//            方法2
//            $("span").click(function () {
//                $("td").each(function () {
//                    var a = $(this).find("input").val();
//                    if ($(this).find("span").hasClass("aa")) {
//                        alert("该值已被输入");
//                    } else {
//                        $(this).append("<span class='aa'>" + a + "</span>");
//                    }
//                });
//            });
        </script>
    </body>
</html>
